<!--
 * @Author: your name
 * @Date: 2022-02-23 09:56:51
 * @LastEditTime: 2022-02-24 09:09:08
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \day03\3-浮动.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>子元素浮动对父元素的影响</title>
    <style>
        
        .parent{
            border: 10px solid blue;
            margin: 10px;
           
        }
        .child{
           /*  width: 100px; */
          /*  width: 100%; */
          /* calc计算宽度 */
           width: calc(100% - 20px);
            height: 100px;
            margin: 10px;
            background-color: red;
            float: right;
        }
        .clear{
            /* 对父元素兄弟元素造成影响，给兄弟元素清除浮动 clear：both */
            clear: both;
        }
        .clear2{
            /* 子元素浮动，父元素失去子元素支撑，使用overflow，使子元素高度继续撑起父元素 */
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="parent">hello</div>
    <div class="parent clear2" >
        <div class="child">1</div>
        <div class="child">2</div>
        <div class="child">3</div>
        <div class="child">4</div>
    </div>
    <div class="parent clear">word</div>
</body>
</html>